<?php


	
	$ini_array = parse_ini_file("config/config.ini");
	
	
	
	$destination_folder = "picture/scannerFile/";
	if( !file_exists($destination_folder) ){
		mkdir($destination_folder, 0777, true);
	}
	date_default_timezone_set($ini_array["default_timezone"]);
	$datetime = date("YmdHis");
	$oldFilePath = $_POST["oldFile"];
	$ID = $_POST["ID"];
	//if( $oldFilePath != "" ){
	//	unlink($oldFilePath);
	//}
	
	$funcName = $_POST["funcName"];
	
	

	$file = $_FILES["scannerFile"];

	
	if( $file["error"] == 0 ){
		$suffix = substr($file["name"], strrpos($file["name"], '.'));
		if( move_uploaded_file($file["tmp_name"], $destination_folder.$datetime.$suffix) == false ){
			echo "<script>parent.".$funcName."('',$ID, -1)</script>";
		}else{
			echo "<script>parent.".$funcName."('".$destination_folder.$datetime.$suffix."', $ID, 0)</script>";
		}
	}else{
		echo "<script>parent.".$funcName."('',$ID, ".$file["error"].")</script>";
	}
	

	
	
	


?>
